package com.itheima.nacos.comtroller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Service2Controller {

    @Autowired
    ConfigurableApplicationContext applicationContext;

    @Value("${common.name}")
    private String config2;


    @GetMapping("/getconfig2")
    public String getConfig2(){
//        return "获取的配置为: " + config2;
        return applicationContext.getEnvironment().getProperty("common.name");
    }
}
